package com.cyh.web.domain;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.cyh.core.framework.common.model.TreeNode;
import com.fasterxml.jackson.annotation.JsonIgnore;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author: yanhang_chen
 * @Date: 2020/9/14 9:36
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MenuTreeNode implements TreeNode<String,MenuTreeNode> {

    private String nodeId;

    private String title;

    private List<MenuTreeNode> children;

    private String parentId;


    //自定义方法

    public String getNodeId() {
        return nodeId;
    }

    public void setNodeId(String nodeId) {
        this.nodeId = nodeId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public List<MenuTreeNode> getChildren() {
        return children;
    }

    public void setChildren(List<MenuTreeNode> children) {
        this.children = children;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }


    //重写的方法

    @JsonIgnore
    @Override
    public String getCurrentNodeId() {
        return nodeId;
    }

    @JsonIgnore
    @Override
    public String getParentNodeId() {
        return parentId;
    }

    @Override
    public void addChildNode(MenuTreeNode childNode) {
        if(children==null){
            children = new ArrayList<>();
        }
        children.add(childNode);
    }

    @JsonIgnore
    @Override
    public Collection<MenuTreeNode> getChildNodes() {
        return children;
    }
}
